package com.ruoyi.web.controller.wx;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.BySchool;
import com.ruoyi.system.domain.BySubjectClassify;
import com.ruoyi.system.service.IBySchoolService;
import com.ruoyi.system.service.IBySubjectClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx/index")
public class WxIndexController {
    @Autowired
    private IBySchoolService schoolService;

    @Autowired
    private IBySubjectClassifyService bySubjectClassifyService;


    @PostMapping("index")
    @GetMapping("index")
    public AjaxResult index(){
        System.out.println("yyyyyyyyyy-mmmmmmmmmmmmmm-ddddddddddddd");
        return AjaxResult.success();
    }


    /**
     * 获取院校的参数
     */
    @GetMapping("getSchoolName")
    public AjaxResult getSchoolName(){
        List<BySchool> list = schoolService.queryAll();
        return AjaxResult.success(list);
    }

    /**
     * 获取学习阶段
     */
    @GetMapping("getTopSubject")
    public AjaxResult getTopSubject(){
        List<BySubjectClassify> list = bySubjectClassifyService.queryTopSubject();
        return AjaxResult.success(list);
    }


    /**
     * 根据选择的学习阶段，获取对应的科目
     */
    @PostMapping("getSubjectForParam")
    public AjaxResult getSubjectForParam(@RequestBody String subject){
        // System.out.println(subject);
        JSONObject json = JSONObject.parseObject(subject);
        String subjectStr = json.getString("subject");

        List<JSONObject> list = bySubjectClassifyService.querySubjectForPid(subjectStr);

        return AjaxResult.success(list);
    }
}
